<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <P>1!+2!+3!+4!+5!…20!</P>
    <P id="p"></P>
</body>
<script>
    var i;
    var p = document.getElementById('p');
    var sum = 0;
    for (i = 1; i <= 20; i++) {
        var j;
        var k = 1;
        for (j = 1; j <= i; j++) {
            k *= j;
        }
        sum += k;
    }
    p.innerHTML = '=' + sum;
</script>

</html>